package com.oic.eurekaClient.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.RestTemplate;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.ribbon.proxy.annotation.Hystrix;

@Controller
public class TestController {

	@Value("${server.port}")
	private Integer port;
	
	@Autowired
	RestTemplate restTemplate;
	@ResponseBody
	@RequestMapping("/rest")
	@HystrixCommand(fallbackMethod="hytrix")
	public String rest(){
		String a=restTemplate.getForObject("http://EUREKACLIENT/rest2", String.class);
		return a;
	}
	
	@ResponseBody
	@RequestMapping("/rest2")
	public String rest2(){
		return "this is rest2:"+port;
	}
}
